package Computer.Event;
import Computer.Main.*;

public class JumpEq implements Instruction {

	private Pointer ptr1;
	private Pointer ptr2;
	private int pos;
	
	public JumpEq(int pos, Pointer ptr1, Pointer ptr2) {
		this.ptr1 = ptr1;
		this.ptr2 = ptr2;
		this.pos = pos;
	}
	
	@Override
	public void execute(Memory memory, ProgramCounter counter) {
		if(ptr1.getWord(memory).equals(ptr2.getWord(memory)))
			counter.setNextAddress(pos);
		else
			counter.increment();
	}
	
	public String toString() {
		return "JEQ " + pos + " " + ptr1 + " " + ptr2;
	}
}
